package subject_set.interview.Day3_25_meituan;

/**
 * @author haomin
 * @date 2023/03/25 20:30
 **/
import java.util.*;
public class Main4{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] arr1 = in.nextLine().trim().split(";");
        Map<String, String> map = new HashMap<>();
        for(String str : arr1){
            String[] ss = str.split("=");
            map.put(ss[0], ss[1]);
        }
        int n = Integer.parseInt(in.nextLine().trim());
        for(int i = 0; i <= n; i++) {
            String ent = in.nextLine().trim();
            if(map.containsKey(ent))
                System.out.println(map.get(ent));
            else
                System.out.println("EMPTY");
        }
    }

}